/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.teamreinforce.ejb.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author tidiane
 */
@Entity
@Table(name = "collaborateur")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Collaborateur.findAll", query = "SELECT c FROM Collaborateur c"),
    @NamedQuery(name = "Collaborateur.findByIdCollaborateur", query = "SELECT c FROM Collaborateur c WHERE c.idCollaborateur = :idCollaborateur"),
    @NamedQuery(name = "Collaborateur.findByNom", query = "SELECT c FROM Collaborateur c WHERE c.nom = :nom"),
    @NamedQuery(name = "Collaborateur.findByPrenom", query = "SELECT c FROM Collaborateur c WHERE c.prenom = :prenom"),
    @NamedQuery(name = "Collaborateur.findByTelephone", query = "SELECT c FROM Collaborateur c WHERE c.telephone = :telephone"),
    @NamedQuery(name = "Collaborateur.findByPortable", query = "SELECT c FROM Collaborateur c WHERE c.portable = :portable"),
    @NamedQuery(name = "Collaborateur.findByEmail", query = "SELECT c FROM Collaborateur c WHERE c.email = :email"),
    @NamedQuery(name = "Collaborateur.findByLogin", query = "SELECT c FROM Collaborateur c WHERE c.login = :login"),
    @NamedQuery(name = "Collaborateur.findByPassword", query = "SELECT c FROM Collaborateur c WHERE c.password = :password"),
    @NamedQuery(name = "Collaborateur.findByEstAdmin", query = "SELECT c FROM Collaborateur c WHERE c.estAdmin = :estAdmin")})
public class Collaborateur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_collaborateur")
    private Integer idCollaborateur;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "nom")
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "prenom")
    private String prenom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "telephone")
    private String telephone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "portable")
    private String portable;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "login")
    private String login;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "password")
    private String password;
    @Column(name = "est_admin")
    private Integer estAdmin;
    @JoinTable(name = "realise", joinColumns = {
        @JoinColumn(name = "id_collaborateur", referencedColumnName = "id_collaborateur")}, inverseJoinColumns = {
        @JoinColumn(name = "id_tache", referencedColumnName = "id_tache")})
    @ManyToMany
    private List<Tache> tacheList;
    @JoinTable(name = "assiste", joinColumns = {
        @JoinColumn(name = "id_collaborateur", referencedColumnName = "id_collaborateur")}, inverseJoinColumns = {
        @JoinColumn(name = "id_reunion", referencedColumnName = "id_reunion")})
    @ManyToMany
    private List<Reunion> reunionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collaborateur")
    private List<Reponse> reponseList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collaborateur")
    private List<Sujet> sujetList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collaborateur")
    private List<Role> roleList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "collaborateur")
    private List<Notification> notificationList;

    public Collaborateur() {
    }

    public Collaborateur(Integer idCollaborateur) {
        this.idCollaborateur = idCollaborateur;
    }

    public Collaborateur(Integer idCollaborateur, String nom, String prenom, String telephone, String portable, String email, String login, String password) {
        this.idCollaborateur = idCollaborateur;
        this.nom = nom;
        this.prenom = prenom;
        this.telephone = telephone;
        this.portable = portable;
        this.email = email;
        this.login = login;
        this.password = password;
    }

    public Integer getIdCollaborateur() {
        return idCollaborateur;
    }

    public void setIdCollaborateur(Integer idCollaborateur) {
        this.idCollaborateur = idCollaborateur;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getPortable() {
        return portable;
    }

    public void setPortable(String portable) {
        this.portable = portable;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getEstAdmin() {
        return estAdmin;
    }

    public void setEstAdmin(Integer estAdmin) {
        this.estAdmin = estAdmin;
    }

    @XmlTransient
    public List<Tache> getTacheList() {
        return tacheList;
    }

    public void setTacheList(List<Tache> tacheList) {
        this.tacheList = tacheList;
    }

    @XmlTransient
    public List<Reunion> getReunionList() {
        return reunionList;
    }

    public void setReunionList(List<Reunion> reunionList) {
        this.reunionList = reunionList;
    }

    @XmlTransient
    public List<Reponse> getReponseList() {
        return reponseList;
    }

    public void setReponseList(List<Reponse> reponseList) {
        this.reponseList = reponseList;
    }

    @XmlTransient
    public List<Sujet> getSujetList() {
        return sujetList;
    }

    public void setSujetList(List<Sujet> sujetList) {
        this.sujetList = sujetList;
    }

    @XmlTransient
    public List<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    @XmlTransient
    public List<Notification> getNotificationList() {
        return notificationList;
    }

    public void setNotificationList(List<Notification> notificationList) {
        this.notificationList = notificationList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCollaborateur != null ? idCollaborateur.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Collaborateur)) {
            return false;
        }
        Collaborateur other = (Collaborateur) object;
        if ((this.idCollaborateur == null && other.idCollaborateur != null) || (this.idCollaborateur != null && !this.idCollaborateur.equals(other.idCollaborateur))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.teamreinforce.ejb.entities.Collaborateur[ idCollaborateur=" + idCollaborateur + " ]";
    }
    
}
